<template>
    <!-- <div>
      <van-icon color="#777" name="good-job-o"/> 
    </div>-->
    <van-button
        class="like-btn"
        type="default"
        size="small"
        :icon="value==1?'good-job':'good-job-o'"
        :loading="btnloading"
        @click="isLikefunc"
    >=={{value}}</van-button>
</template>
           
<script>
import { addLike_api, deleteLike_api } from '@/api/article'
export default {
  props: {
    value: {
      type: [String, Number, Boolean, Object]
    },
    artId: {
      type: [String, Number, Boolean, Object],
      required: true
    }
  },
  data() {
    return {
      btnloading: false
    }
  },
  methods: {
    async isLikefunc() {
        this.btnloading=true
      if (this.value == 1) {
        //  已经点赞了，应该取消点赞
        this.$emit('input', -1)
        const { data: res } = await deleteLike_api(this.artId)
      } else {
        //  需要点赞
        this.$emit('input', 1)
        const { data: res } = await addLike_api(this.artId)
      }
      this.btnloading=false
    }
  }
}
</script>
<style scoped lang='less'>
.like-btn.van-button--default {
  color: #323233;
  background-color: #fff;
  border: none;
  font-size: 40px;
}
</style>